<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登陆</title>
</head>
<body>
<p>**********************登陆**********************</p>
<form action="/users/login"  method="post">
    <label for="username">用 &nbsp;户&nbsp; 名：</label>
    <input type="text" name="username" id="username" required="required"/>
    <br />
    <!--<label for="phone">手 &nbsp;机：</label>-->

    <!--<input type="tel" name="phone" id="phone" required="required">-->
    <label for="psw">密 &nbsp;&#x3000;&nbsp; 码：</label>
    <input type="password" name="psw" id="psw" required="required"/>
    <br />
    <input type="submit" value="登陆"/>
</form>

<p></p>
</body>
<script src="/js/jquery.min.js"></script>
<script>
    var pVlae = document.getElementsByTagName('p')[0];

    function randomWord(randomFlag, min, max){
        var str = "",
            range = min,
            arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];

        // 随机产生
        if(randomFlag){
            range = Math.round(Math.random() * (max-min)) + min;
        }
        for(var i=0; i<range; i++){
            pos = Math.round(Math.random() * (arr.length-1));
            str += arr[pos];
        }
        return str;
    }

    var random = randomWord(true,8,8);

    pVlae.innerText = random;
    $('form').submit(function (event) {
        event.preventDefault();
        var data = $(this).serialize();
        $.post('/users/login',data,function (resData) {
            console.log(resData.message);
        })
    })

</script>
</html>